package com.huizu.project.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.huizu.common.annotation.Log;
import com.huizu.common.core.controller.BaseController;
import com.huizu.common.core.domain.AjaxResult;
import com.huizu.common.enums.BusinessType;
import com.huizu.project.domain.ProLabourEducationConfig;
import com.huizu.project.service.IProLabourEducationConfigService;
import com.huizu.common.utils.poi.ExcelUtil;
import com.huizu.common.core.page.TableDataInfo;

/**
 * 劳动教育配置Controller
 * 
 * @author pjl
 * @date 2024-09-10
 */
@RestController
@RequestMapping("/project/config")
public class ProLabourEducationConfigController extends BaseController
{
    @Autowired
    private IProLabourEducationConfigService proLabourEducationConfigService;

    /**
     * 查询劳动教育配置列表
     */
    @PreAuthorize("@ss.hasPermi('project:config:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProLabourEducationConfig proLabourEducationConfig)
    {
        startPage();
        List<ProLabourEducationConfig> list = proLabourEducationConfigService.selectProLabourEducationConfigList(proLabourEducationConfig);
        return getDataTable(list);
    }

    /**
     * 查询劳动教育配置列表（无权限无需登录）
     * @param proLabourEducationConfig
     * @return
     */
    @GetMapping("/listNoAccess")
    public TableDataInfo listNoAccess(ProLabourEducationConfig proLabourEducationConfig)
    {
        startPage();
        List<ProLabourEducationConfig> list = proLabourEducationConfigService.selectProLabourEducationConfigList(proLabourEducationConfig);
        return getDataTable(list);
    }

    /**
     * 导出劳动教育配置列表
     */
    @PreAuthorize("@ss.hasPermi('project:config:export')")
    @Log(title = "劳动教育配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProLabourEducationConfig proLabourEducationConfig)
    {
        List<ProLabourEducationConfig> list = proLabourEducationConfigService.selectProLabourEducationConfigList(proLabourEducationConfig);
        ExcelUtil<ProLabourEducationConfig> util = new ExcelUtil<ProLabourEducationConfig>(ProLabourEducationConfig.class);
        util.exportExcel(response, list, "劳动教育配置数据");
    }

    /**
     * 获取劳动教育配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('project:config:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(proLabourEducationConfigService.selectProLabourEducationConfigById(id));
    }

    /**
     * 新增劳动教育配置
     */
    @PreAuthorize("@ss.hasPermi('project:config:add')")
    @Log(title = "劳动教育配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProLabourEducationConfig proLabourEducationConfig)
    {
        return toAjax(proLabourEducationConfigService.insertProLabourEducationConfig(proLabourEducationConfig));
    }

    /**
     * 修改劳动教育配置
     */
    @PreAuthorize("@ss.hasPermi('project:config:edit')")
    @Log(title = "劳动教育配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProLabourEducationConfig proLabourEducationConfig)
    {
        return toAjax(proLabourEducationConfigService.updateProLabourEducationConfig(proLabourEducationConfig));
    }

    /**
     * 删除劳动教育配置
     */
    @PreAuthorize("@ss.hasPermi('project:config:remove')")
    @Log(title = "劳动教育配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(proLabourEducationConfigService.deleteProLabourEducationConfigByIds(ids));
    }
}
